<script type="text/javascript" src="/js/projects.projects.js"></script>
<script>
    var riaItem;
    var itemDataSource = {
        name: "bruno",
        age: 31,
        birth: '1977-09-26'
    };
    var listItemsDataSource = [
        {
            id: 4,
            name: "bruno",
            age: 31,
            birth: '1977-09-26'
        },
        {
            id: 5,
            name: "luana",
            age: 27,
            birth: '1970-09-26'
        },
        {
            id: 7,
            name: "anna",
            age: 7,
            birth: '1970-09-26'
        }
    ];

    var listDataSource = {
            name: "lista de coisas"
    };

    $(document).ready(function() {
        riaItem = ria.buildItem({
            commands: {
                'a' : function(spec,jsonParams) {
                    console.log('a');
                    console.log(spec);
                    console.log(jsonParams);
                }
            }
        })
        .setJsObjName('riaItem')
        .setDs(itemDataSource)
        .setElement($('#itemContainer'))
        .setTpls({
                view: "<?php echo $viewTpl ?>",
                form: "<?php echo $formTpl ?>"
        })
        .setDecorators({
                edit: "<?php echo $editDecorator ?>",
                view: "<?php echo $viewDecorator ?>"
        })
        .setViews({
                view: {tpl:'view'},
                //view: {tpl:'view',decorator:'view'},
                edit: {tpl:'form',decorator:'edit'}
        })
        .setExtraTplValue('_formId','riaItemForm')
        .setActualView('edit');
        //.display();*/




        riaList = ria.buildList()
        .setJsObjName('riaList')
        .setDs(listDataSource)
        .setItemsDs(listItemsDataSource)
        .setElement($('#listContainer'))
        .setRiaObject(riaItem)
        .setExtraItemTplValues({
            _jsObjName : 'riaItem-${dsId}',
            _requestObjName : 'riaItem',
            _formId : 'form-riaItem-${count}'
        })
        .setTpls({
                table: "<?php echo $tableTpl ?>",
                list: "<?php echo $listTpl ?>"
        })
        .setItemDecorators({
                td: "<?php echo $tdListItemDecorator ?>",
                div: "<?php echo $divListItemDecorator ?>"
        })
        .setViews({
                table: {tpl:'table',itemDecorator:'td'},
                list:  {tpl:'list',itemDecorator:'div'}
        }).display('table');
    });

</script>
<button onclick="riaItem.setActualView('edit').display()"> change view </button>
<div id='itemContainer'>
</div>

<div id='listContainer'>
</div>

